export default {
    state: {
        isCollapse: false,
        tabList: [
            {
                path: '/',
                name: 'index',
                label: '首页',
                icon: 's-home',
                url: 'index'
            }
        ],
        menuList: [],
        routearr: []
    },
    mutations: {
        collapseChange(state) {
            state.isCollapse = !state.isCollapse
        },
        tagChange(state, val) {
            if (val.name === 'main') { return }
            const index = state.tabList.findIndex(item =>
                item.name === val.name
            )
            if (index === -1) {
                state.tabList.push(val)
            }
        },
        menuChange(state, routespath) {
            state.routearr = routespath
            state.menuList = []
            for(var i=1;i<routespath.length;i++){
                let tepm = { path: routespath[i].path, name: routespath[i].name, label: routespath[i].meta.label }
                state.menuList.push(tepm)
            }
            // state.menuList = [{
            //     // label: "首页",
            //     // name: "index",
            //     // path: '/index',
            // }]
            // if (routespath[0].path !== '/index') {
            //     routespath.forEach(element => {
            //         let tepm = { path: element.path, name: element.name, label: element.meta.label }
            //         state.menuList.push(tepm)
            //     });
            // }
        }
    }
}